<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/common/includes.jsp" %>

<html>

 <head>
    
    <title>科目信息管理</title>
    <!-- import css and js -->
	<%@ include file="/common/meta.jsp" %>
		<script src="${ctx}/js/jsp/comm.js" type="text/javascript"></script>
	<script type="text/javascript">
		var basic_Url="${ctx}/basic/subjects";
		var basic_WUrl="basic/subjects";
		var basic_Title="科目";
		var show_Width=520;
		var show_Hight=300;
		var actionNodeID=null;
		function createSearch(){
			init(1,8,'140,140,140,140,140,140','25%');

			//第一行的数据
			addCommon(0,0,"lable","名称：");
			addCommon(0,1,"txtlike","zd002Name");
			addCommon(0,2,"lable","编码：");
			addCommon(0,3,"txtlike","zd001Code");
			addCommon(0,4,"lable","助记码：");
			addCommon(0,5,"txtlike","bizMnemonic");
		}
		function searchAP(){			
			multipleSearch("#table1",true,"",basic_Url+"/list.do");
		}
		 function getSelected(){
			 var grid = $("#table1").ligerGetGridManager(); 
				var rows = grid.getCheckedRows();
				if(rows.length==0){
					$.dialog.alert("请选择一行数据!");
					return null;
				}else{
					return rows[0];
				}
			}
		 
		 $(function(){
			//创建JQGRID表格
				var grid = $("#table1").ligerGrid({
			        columns: [
							  { display: '科目编码', name: 'zd001Code', width: 150 },
			                  { display: '科目名称', name: 'zd002Name', width: 150},
			                  { display: '助记码', name: 'bizMnemonic', width: 120 },
			                  { display: '类别', name: 'zd003CategoryId', width: 120},
			                  { display: '编号位数', name: 'zd004Munber', width: 120}
			                  ],  usePager: true,pageSize:15,
			                      url : basic_Url+"/list.do",method:'POST',enabledSort:false,
			                      width: '100%', height: '98%',pageSizeOptions :[15,25,35], checkbox: true,rownumbers:true,           
			                      onDblClickRow : function (data, rowindex, rowobj){
			                          edit(data);
			                       },toolbar: { items: [
														  { text: '新增', click: additem, icon: 'add' },
														  { line: true },
				                                          { text: '修改', click: getSelected, icon: 'modify' },
				                                          { line: true },
				                                          { text: '删除', click: deleSubject, img: '${ctx}/js/ligerUI/skins/icons/delete.gif' }
				                                          ]
				                                          }
			                  });
				$("#layout1").ligerLayout({ leftWidth: 200,height: '100%',heightDiff:-24,space:4});
				$("#tree1").ligerTree({  
					 url: basic_Url+'/tree.do',
					 nodeWidth: 115,
					 checkbox: false,
			         slide: false,
			         onClick:function(node){
			        	 actionNodeID = node.data.id;
		        		 multipleSearch("#table1",true,"",basic_Url+"/list.do?pid="+node.data.id);
			         }
			     });
				$("#pageloading").hide();
		 });
		 
		//添加物料
		 function additem(){
				var url = "basic/subjects/operate/add/"+actionNodeID+".do";
				ShowIframeDialog("operate","添加物料",url,320,300);
		 }
		
		//修改物料
		 function getSelected(){
			 var grid = $("#table1").ligerGetGridManager(); 
				var rows = grid.getCheckedRows();
				var data =grid.getSelectedRow();
				if(rows.length==0){
					$.dialog.alert("请选择一行数据!");
					return false;
				}else{
					edit(data);
				}
		}
		 function deleSubject(){
			 var manager = $("#table1").ligerGetGridManager(); 
				var rows =manager.getSelectedRows();
				var bol = false;
				if (rows==null || 0 == rows.length){
						$.dialog.alert('请选择需要操作删除的行！');
						return;
				}
				for(var i=0;i<rows.length;i++){
				 	if (rows[i].bizCreatorName != '${user.name}'){
				 		bol = true;
					}
				}
				if(bol){
					$.dialog.alert('请选择自己创建的草稿单据进行删除操作!');
					return;
				}else{
					del();
				}
		 }
		 document.onkeydown=keyListener;   
		 function keyListener(e){   
		     e = e ? e : event;  
		     if(e.keyCode == 13){   
		     	searchAP();
		     }   
		 }  
	</script>
  </head>
<body onLoad="createSearch()">
 <!--   <div id="layout1">
          <div class="panelBar">
	            <ul class="toolBar">
		           <li><a class="add" onclick="add()">
		           <span>添加</span></a></li>
				   <li><a class="delete" onclick="del()"><span>删除</span></a></li>
               </ul>
          </div>
          <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      </div> -->
      <div id="pageHeader" class="pageHeader">
               <div class="searchBar" id="multipleSearchDialog">
	                <table class="table" width="100%" id="searchHeader" >  
                        <tbody id="newbody">
                        </tbody>
 	                </table>
                    <div class="subBar">
			             <ul>
				             <li><div class="buttonActive"><div class="buttonContent"><button type="submit" id="btnSearch" onclick="searchAP()">查询</button></div></div></li>
				             <li><a class="button" onclick="clearSearch()"><span>重置</span></a></li>
			             </ul>
	                </div>
               </div>
          </div>
      <div id="layout1">
            <div position="left" title="科目">
            <div style="width:100%; height:380px; float:left;overflow:auto;">
   				 <ul id="tree1"></ul>
    		</div> 
            </div>
            <div position="center" title="科目" id="table1">
            
            </div>   
      </div>  
      <div class="clear"></div>
</body>
</html>